<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 占位图
        // 先显示占位图
        // 派一个代理对象请求真实的图片地址
        // 交给这个对象  vue和react是基于proxy写出
        //什么高价函数，即返回值是函数
        var myImage = (function (){
            var imgNode = document.createElement('img');
            document.body.appendChild(imgNode);
            return {
                        setSrc: function(src) {
                            imgNode.src = src;
                    }
                }
        })()
        var proxyImage = (function (){
            //闭合空间
            var img=new Image();//DOM 代理对象
            img.onload = function(){
                // 设置一下
                
                //myImage.setSrc(this.src);
            }
            return {
                setSrc(src){
                    // src变量 scope
                    myImage.setSrc('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F458412ef0894476c376deb206e089b27160f46ba4452-nMT6Xd_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1633315734&t=5920234e8cd4c299436c724431d894e6');
                    img.src=src;
                    // console.log(src)
                }
            }
        })()
        proxyImage.setSrc('https://tse3-mm.cn.bing.net/th/id/OIP-C.h5NwXZV015kcEO6cNjgC0wHaKj?w=182&h=260&c=7&r=0&o=5&dpr=1.25&pid=1.7');
    </script>
</body>
</html>